// 导入express模块;
const cookieParser = require('cookie-parser');
const express = require('express');
// 创建express的服务器实例;
const app = express();

const history = require('connect-history-api-fallback')

// 连接数据库
require("./middle/mongoose");

// 中间件
app.use(express.json())
app.use(express.urlencoded({ extended: false }))
app.use(history());

app.use(express.static('./dist'))

// cookie解析
app.use(cookieParser())
//持久化存储
app.use(require('./middle/session'))

require('./addData')


app.use('/',require('./router'))
app.listen(5252, () => {
  console.log('Express server running at http:127.0.0.1:5252');
})